package 一些算法竞赛测试题;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-10-23
 * Time: 13:09
 */
public class Demo15 {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();
        int min = 100000;
        int max = 0;
        Set<Integer> set = new HashSet<>();
        int m = 0;
        int n = 0;
        while(N-- > 0){
            String s = scanner.nextLine();
            String[] str = s.split(" ");
            for(int i = 0; i < str.length; i++){
                 int x = Integer.parseInt(str[i]);
                 min = Math.min(min, x);
                 max = Math.max(max, x);
                 if(set.contains(x)){
                     n = x;
                 }else{
                     set.add(x);
                 }
            }
        }
        for(int i = min; i <= max; i++){
            if(!set.contains(i)){
                m = i;
            }
        }
        System.out.println(m + " " + n);
    }
}
